{{ $baseURL := site.BaseURL }}
{{ $safeURL := .Destination | safeURL }}
{{ if and (ne $baseURL "/") (not (or (strings.HasPrefix $safeURL "https://") (strings.HasPrefix $safeURL "http://") (strings.HasPrefix $safeURL "mailto:"))) }}
{{ $safeURL = printf "%s%s" $baseURL $safeURL }}
{{ end }}
<img src="{{ $safeURL }}"
     {{- with .PlainText }} alt="{{ . }}"{{ end -}}
     {{- with .Title }} title="{{ . }}"{{ end -}}
>
{{- /* chomp trailing newline */ -}}